﻿<Window x:Class="DocumentsTagger.UI.ScannerOptionsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:IO="clr-namespace:System.IO;assembly=mscorlib"
        xmlns:local="clr-namespace:DocumentsTagger.UI"
        Title="Scanner Options" Height="416" Width="517"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner" MinWidth="400" MinHeight="400">
    <Window.Resources>
        <ObjectDataProvider
        x:Key="getDrives"
        MethodName="GetDrives"
        ObjectType="{x:Type IO:DriveInfo}" />
        
        <local:GetFileSysemInformationConverter x:Key="getFileSysemInformationConverter" />
        
        <HierarchicalDataTemplate
            DataType="{x:Type IO:DriveInfo}"
            ItemsSource="{Binding Converter={StaticResource getFileSysemInformationConverter}}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}"
                           Margin="5,0,0,0"/>
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate 
            DataType="{x:Type IO:DirectoryInfo}"
            ItemsSource="{Binding Converter={StaticResource getFileSysemInformationConverter}}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}"
                           Margin="5,0,0,0"/>
            </StackPanel>
        </HierarchicalDataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <DockPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" >
            <Grid VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Label Grid.Row="0" Content="Folders List" Name="lbl1" VerticalAlignment="Top" />
                <TreeView Grid.Row="1"  ItemsSource="{Binding GetDrives}" SelectedItemChanged="TreeView_SelectedItemChanged">
                </TreeView >
            </Grid> 
        </DockPanel>
        <DockPanel Grid.Row="0" Grid.Column="1"  HorizontalAlignment="Left" Width="200">
            <StackPanel>
                <Button Content="Add to Watched Folders" Command="{Binding AddToWatchedDirectoriesComand}"/>
                <Button Content="Remove from Watched Folders"  Command="{Binding RemoveFromWatchedDirectoriesComand}"/>
            </StackPanel>
        </DockPanel>
        
        <DockPanel Grid.Row="1" Grid.Column="1">
            <Grid VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Label Grid.Row="0" Content="Watched Folders" VerticalAlignment="Top" />
                <ListBox Name="ScannedDirectoriesLB"  
                         Grid.Row="1" 
                         SelectionMode="Single" 
                         SelectedItem="{Binding Path=SelectedWatchedDirectory, UpdateSourceTrigger=PropertyChanged}"
                         ItemsSource="{Binding WatchedDirectories}"
                         >
                         
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                                <Label Content="{Binding}" Margin="0,0,0,0" Padding="0,0,0,0">
                                </Label>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </DockPanel>
    </Grid>
</Window>
